﻿using System;
using System.IO;
using SEXY;
using UnityEngine;

// Token: 0x02000189 RID: 393
public class CharaInfo
{
	// Token: 0x06000A29 RID: 2601 RVA: 0x0003BC10 File Offset: 0x00039E10
	public void Load(string fileName)
	{
		this.name = Path.GetFileNameWithoutExtension(fileName);
		using (FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read))
		{
			using (BinaryReader binaryReader = new BinaryReader(fileStream))
			{
				try
				{
					this.Load(binaryReader);
				}
				catch (Exception message)
				{
					GlobalData.Debug_LogError(message);
				}
			}
		}
		this.time = File.GetLastWriteTime(fileName);
	}

	// Token: 0x06000A2A RID: 2602 RVA: 0x0003BCAC File Offset: 0x00039EAC
	public void Load(BinaryReader reader)
	{
		long offset = PNG_Loader.CheckSize(reader);
		reader.BaseStream.Seek(offset, SeekOrigin.Begin);
		string text = reader.ReadString();
		if (text.IndexOf("【PlayHome") == 0)
		{
			this.game = CharaInfo.GAME.PLAY_HOME;
		}
		else if (text.IndexOf("【HoneySelectChara") == 0 || text.IndexOf("【PremiumResortChara") == 0)
		{
			this.LoadSEXY(reader, text);
		}
		else if (text.IndexOf("【HoneySelectClothesFemale】") == 0)
		{
			reader.BaseStream.Seek(offset, SeekOrigin.Begin);
			CharFileInfoClothesFemale charFileInfoClothesFemale = new CharFileInfoClothesFemale();
			charFileInfoClothesFemale.Load(reader, true);
			this.name = charFileInfoClothesFemale.comment;
		}
		else if (text.IndexOf("【HoneySelectClothesMale】") == 0)
		{
			reader.BaseStream.Seek(offset, SeekOrigin.Begin);
			CharFileInfoClothesMale charFileInfoClothesMale = new CharFileInfoClothesMale();
			charFileInfoClothesMale.Load(reader, true);
			this.name = charFileInfoClothesMale.comment;
		}
	}

	// Token: 0x06000A2B RID: 2603 RVA: 0x0003BD98 File Offset: 0x00039F98
	private void LoadSEXY(BinaryReader reader, string mark)
	{
		int num = reader.ReadInt32();
		int num2 = reader.ReadInt32();
		BlockHeader[] array = new BlockHeader[num2];
		for (int i = 0; i < num2; i++)
		{
			array[i] = new BlockHeader();
			array[i].LoadHeader(reader);
		}
		long position = reader.BaseStream.Position;
		foreach (BlockHeader blockHeader in array)
		{
			if (blockHeader.tagName.StartsWith("プレビュー情報"))
			{
				if (mark.IndexOf("【HoneySelectChara") == 0)
				{
					reader.BaseStream.Seek(position + blockHeader.pos, SeekOrigin.Begin);
					this.Load_HoneyPreview(reader, blockHeader.version);
				}
				else if (mark.IndexOf("【PremiumResortChara") == 0)
				{
					reader.BaseStream.Seek(blockHeader.pos, SeekOrigin.Begin);
					this.Load_SBPRPreview(reader, blockHeader.version);
				}
				else
				{
					GlobalData.Debug_LogError(mark);
				}
			}
		}
	}

	// Token: 0x06000A2C RID: 2604 RVA: 0x0003BE9C File Offset: 0x0003A09C
	private void Load_HoneyPreview(BinaryReader br, int saveVer)
	{
		this.game = CharaInfo.GAME.HONEY_SELECT;
		if (saveVer >= 4)
		{
			int num = br.ReadInt32();
		}
		int num2 = br.ReadInt32();
		if (saveVer >= 2)
		{
			int num3 = br.ReadInt32();
			int num4 = br.ReadInt32();
			this.name = br.ReadString();
			int num5 = br.ReadInt32();
			int num6 = br.ReadInt32();
			int num7 = br.ReadInt32();
		}
		if (saveVer >= 4)
		{
			int num8 = br.ReadInt32();
			int num9 = br.ReadInt32();
			int num10 = br.ReadInt32();
			int num11 = br.ReadInt32();
		}
		if (saveVer >= 3)
		{
			int num12 = br.ReadInt32();
		}
	}

	// Token: 0x06000A2D RID: 2605 RVA: 0x0003BF34 File Offset: 0x0003A134
	private void Load_SBPRPreview(BinaryReader br, int saveVer)
	{
		this.game = CharaInfo.GAME.SEXY_BEACH;
		br.BaseStream.Seek(1L, SeekOrigin.Current);
		if (saveVer >= 1)
		{
			int num = br.ReadInt32();
		}
		this.name = br.ReadString();
		byte b = br.ReadByte();
		int num2 = br.ReadInt32();
		byte b2 = br.ReadByte();
		byte b3 = br.ReadByte();
		int num3 = br.ReadInt32();
	}

	// Token: 0x04000A3D RID: 2621
	public string name = "名無し";

	// Token: 0x04000A3E RID: 2622
	public DateTime time;

	// Token: 0x04000A3F RID: 2623
	public CharaInfo.GAME game = CharaInfo.GAME.UNKNOWN;

	// Token: 0x0200018A RID: 394
	public enum GAME
	{
		// Token: 0x04000A41 RID: 2625
		UNKNOWN = -1,
		// Token: 0x04000A42 RID: 2626
		SEXY_BEACH,
		// Token: 0x04000A43 RID: 2627
		HONEY_SELECT,
		// Token: 0x04000A44 RID: 2628
		PLAY_HOME
	}
}
